/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.googlecode.jsimplemarket.model;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author Alexandru.Codescu
 */
@Entity
@Table(name = "creante")
public class Creanta extends AbstractEntitate {
    private Taxa taxa;
    private Date dataInceput;
    private Date dataSfarsit;
    private BigDecimal valoare;
    private NStareCreanta stareCreanta;
    private List<Plata> plati;
    private BigDecimal valoareReziduala;
    private Inchiriere inchiriere;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "ID_TAXA")
    public Taxa getTaxa() {
        return taxa;
    }

    public void setTaxa(Taxa taxa) {
        this.taxa = taxa;
    }

    @Column(name = "DATA_INCEPUT")
    @Temporal(TemporalType.DATE)
    public Date getDataInceput() {
        return dataInceput;
    }

    public void setDataInceput(Date dataInceput) {
        this.dataInceput = dataInceput;
    }

    @Column(name = "DATA_SFARSIT")
    @Temporal(TemporalType.DATE)
    public Date getDataSfarsit() {
        return dataSfarsit;
    }

    public void setDataSfarsit(Date dataSfarsit) {
        this.dataSfarsit = dataSfarsit;
    }

    @Column(name = "VALOARE", nullable = false)
    public BigDecimal getValoare() {
        return valoare;
    }

    public void setValoare(BigDecimal valoare) {
        this.valoare = valoare;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "ID_STARE_CREANTA")
    public NStareCreanta getStareCreanta() {
        return stareCreanta;
    }

    public void setStareCreanta(NStareCreanta stareCreanta) {
        this.stareCreanta = stareCreanta;
    }

    @OneToMany(fetch = FetchType.LAZY, mappedBy = "creanta")
    public List<Plata> getPlati() {
        return plati;
    }

    public void setPlati(List<Plata> plati) {
        this.plati = plati;
    }

    @Column(name = "VALOARE_REZIDUALA", nullable = false)
    public BigDecimal getValoareReziduala() {
        return valoareReziduala;
    }

    public void setValoareReziduala(BigDecimal valoareReziduala) {
        this.valoareReziduala = valoareReziduala;
    }
    
    @OneToOne(fetch = FetchType.LAZY, optional = true)
//    @Cascade({CascadeType.SAVE_UPDATE, CascadeType.DELETE})
    @JoinColumn(name = "ID_INCHIRIERE")
    public Inchiriere getInchiriere() {
        return inchiriere;
    }

    public void setInchiriere(Inchiriere inchiriere) {
        this.inchiriere = inchiriere;
    }
}
